#ifndef RECORDSYSTEM_CPP
#define RECORDSYSTEM_CPP

#include <windows.h>
#include <mmsystem.h>
#include <iostream>
#include <cstdio>
#include <fstream>
#include "GlobalError.h"

#define HEADERSIZE 23
#define BUFSIZE 8192

/*-------------------------------------------------------------------------------------
--
--	CLASS: RecordSystem
--
--	Date: April 2, 2010
--
--	REVISIONS (Date and Description):
--
--	DESIGNER: John Kuo
--
--	PROGRAMMER: Brad Paugh, John Kuo
--
--  INTERFACE: class RecordSystem
--
--  RETURNS: N/A
--
--	NOTES: Handles the processing of a microphone sound file.
--
-------------------------------------------------------------------------------------*/
class RecordSystem
{
	public:
        RecordSystem();
		void startRecording();
		void makeHeader(char headerData[23]);
		void getNextBuffer(char* buffer);
		int getMsPerPacket(int packetSize);
		void close();
		void waveInProcInstance();
		static void waveInProc(void* param);

	private:
		WAVEHDR* headers;
		char** bufferData;
		HWAVEIN inputDevice;
		WAVEFORMATEX format;
		int currentBuffer;
		int bufferToGet;
		bool threadStop;
		HANDLE bufferFullEvent;
		HANDLE canRead;
};

#endif
